package com.zzx.auth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzx.auth.model.SysMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * 系统菜单仓储层
 */
public interface SysMenuMapper  extends BaseMapper<SysMenu> {

    /**
     * 获取菜单
     *
     * @param username 用户名
     * @return 菜单表单
     */
    @Select("SELECT DISTINCT m.perms FROM sys_menu m LEFT JOIN sys_role_menu rm ON m.menu_id = rm.menu_id LEFT JOIN sys_role r on r.role_id = rm.role_id LEFT JOIN sys_user_role ur ON ur.role_id = r.role_id LEFT JOIN sys_user u on u.user_id = ur.user_id WHERE u.user_name = #{username} AND r.status = 0 AND r.del_flag = 0")
    Set<String> getMenuPermsByUserName(@Param("username") String username);

}
